﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace Bingo.SSQ
{
    public partial class ucRate : UserControl
    {
        public ucRate()
        {
            InitializeComponent();
        }

        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            this.statusStrip.BackColor = this.ParentForm.BackColor;
        }

        #region Event

        #region Button

        private void btnRed_Click(object sender, EventArgs e)
        {
            DataTable dt = BingoLib.SSQ.Number.getRedCount(this.dtpStart.Value.ToString("yyyy-MM-dd"), this.dtpEnd.Value.ToString("yyyy-MM-dd"));
            BingoLib.DrawingCurve myImage = new BingoLib.DrawingCurve();
            myImage.Table = dt;
            myImage.Distance = new int[] { 15, 10, 15, 10 };
            myImage.Title = "红球频率统计";
            myImage.TitleHeight = 20;
            myImage.TitleLocation = new Point(280, 0);
            myImage.TitleFont = new Font("微软雅黑", 20, FontStyle.Regular);
            myImage.RecWidth = 5;
            myImage.MarkUpLeft = -10;
            myImage.MarkDownLeft = -5;
            myImage.ImgSize = this.pictureBox1.Size;
            this.pictureBox1.Image = myImage.DrawingImg();
        }

        private void btnBlue_Click(object sender, EventArgs e)
        {

        }

        #endregion

        #region PictureBox

        private void picClose_MouseEnter(object sender, EventArgs e)
        {
            this.picClose.Image = Properties.Resources.close01;
        }

        private void picClose_MouseLeave(object sender, EventArgs e)
        {
            this.picClose.Image = Properties.Resources.close02;
        }

        private void picClose_Click(object sender, EventArgs e)
        {
            if (((Bingo)this.ParentForm).myThread != null && ((Bingo)this.ParentForm).myThread.IsAlive)
            {
                if (MessageBox.Show("正在进行操作，确定要退出吗？", "系统提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.Cancel)
                {
                    return;
                }
                ((Bingo)this.ParentForm).myThread.Abort();
            }
            this.Dispose();
        }

        #endregion

        #endregion
    }
}
